package controladores;

import color.Color;
import factory.EnvaseAbstractFactory;
import factory.EnvaseFactory;
import factory.FactoryCristalColor;
import factory.FactoryPlasticoColor;
import figuraGeometrica.FiguraGeometrica;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class ControladorEnvase implements Serializable {

    EnvaseAbstractFactory plasCol;
    EnvaseAbstractFactory crisCol;
    
    EnvaseFactory envFac;
    
    String tipoEnvase;
    String figura;
    String color;
    
    List<FiguraGeometrica> figuras = new LinkedList();
    List<Color> colores = new LinkedList();
    
    List<EnvaseFactory> envases = new LinkedList();

    public ControladorEnvase() {
        FiguraGeometrica fiGeo = new FiguraGeometrica();
        figuras = fiGeo.getFiguras();

        Color clr = new Color();
        colores = clr.getColores();
    }

    public List<EnvaseFactory> getEnvases() {
        return envases;
    }

    public void setEnvases(List<EnvaseFactory> envases) {
        this.envases = envases;
    }

    public String getTipoEnvase() {
        return tipoEnvase;
    }

    public void setTipoEnvase(String tipoEnvase) {
        this.tipoEnvase = tipoEnvase;
    }

    public String getFigura() {
        return figura;
    }

    public void setFigura(String figura) {
        this.figura = figura;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public List<FiguraGeometrica> getFiguras() {
        return figuras;
    }

    public void setFiguras(List<FiguraGeometrica> figuras) {
        this.figuras = figuras;
    }

    public List<Color> getColores() {
        return colores;
    }

    public void setColores(List<Color> colores) {
        this.colores = colores;
    }

    public void crearEnvase() {

        if (tipoEnvase.equals("Plastico")) {
            plasCol = new FactoryPlasticoColor(figura, color);
            envFac = new EnvaseFactory(plasCol);
            envases.add(envFac);
        }

        if (tipoEnvase.equals("Cristal")) {
            crisCol = new FactoryCristalColor(figura, color);
            envFac = new EnvaseFactory(crisCol);
            getEnvases().add(envFac);
        }
    }
}
